package com.shop.admin.controller;

import com.shop.admin.result.ApiResult;
import com.shop.admin.service.TakeoutMerchantService;
import com.shop.admin.utils.PageUtils;
import com.shop.admin.valid.UpdateGroup;
import com.shop.admin.vo.TakeoutMerchantUpdateVo;
import com.shop.admin.vo.UserStatusVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@Api(tags = {"TakeoutMerchantController"},description = "外卖商家加盟接口")
@RestController
@RequestMapping("/api/takeout/merchant")
public class TakeoutMerchantController {

    @Resource
    private TakeoutMerchantService takeoutMerchantService;

    /**
     * 加盟商家列表
     */
    @GetMapping("/list")
    @ApiOperation(value = "get加盟商家列表",notes = "page,limit,key封装加盟商家id或加盟商家名称，商家联系电话,负责人，审核状态。必须携带page,limit")
    public ApiResult list(@ApiParam("参数为：page,limit,key,name,mobile,status")@RequestParam Map<String, Object> params){
        PageUtils page = takeoutMerchantService.queryPage(params);
        return ApiResult.ok(page);
    }

    /**
     * 加盟商家修改
     */
    @PostMapping("/update")
    @ApiOperation(value = "修改加盟商家",notes = "id，商户名称,联系电话,负责人,所属省份,所属市,所属区,详细地址,门店Logo,审核状态,是否有效")
    public ApiResult update(@ApiParam("参数为：id,name，mobile,principalName,province,city,area,address,logo,state（0：未审核，1：通过；2：不通过）,isValid [0->无效 1->有效]")@Validated(UpdateGroup.class) @RequestBody TakeoutMerchantUpdateVo vo){
        takeoutMerchantService.updateTakeoutMerchant(vo);
        return ApiResult.ok("修改成功！");
    }


}
